<?php
/**
 * Url creation helper class for EICms
 * 
 * @package EICms
 * @author hcderaad
 *
 */

/**
 * Url creation helper class for EICms
 * 
 * @package EICms
 * @author hcderaad
 *
 */
class EICms_Url {
	
	/**
	 * Creates a valid url for use with the EICms.
	 *
	 * @param string $controller Default 'index'.
	 * @param string $action Default 'index'.
	 * @param array $params Onedimensional array containing key/value params.
	 * @param string $module Default 'default'.
	 * @return string The constructed url.
	 */
	public static function get($controller = 'index', $action = 'index', $params = array(), $module = 'default') {
		$url = Bootstrap::$registry->config->bootstrap->base_domain . Bootstrap::$registry->config->bootstrap->base_url;
		if($module != 'default') {
			$url .= '/' . $module;
		}
		$url .= '/' . $controller . '/' . $action;
		if(!empty($params)) {
			foreach($params as $paramKey => $paramVal) {
				$url .= '/' . $paramKey . '/' . $paramVal;
			}
		}
		return $url;
	}
}
?>